A cluster includes multiple clients, and in order to obtain a processing permission, such as a write permission or a read permission, of a shared resource in the cluster, a client needs to apply to a lock server in the cluster for a processing permission, which is generally referred to as applying for a lock. Generally, the write permission is also referred to as a write lock or an exclusive lock, and the read permission is referred to as a read lock or a shared lock.
In a manner of applying for a write lock by a client, as shown in FIG. 1, a cluster includes a lock server, a client A, and a client B. The client A writes an identifier of the client A into a memory address of the lock server using the Remote Direct Memory Access (RDMA) protocol, for example, applying to the lock server for a write lock using an atomic operation Compare-and-Swap in the RDMA protocol, that is, the client A obtains a write lock by applying to the lock server, that is, the write lock is allocated to the client A. The client B applies to the lock server for the write lock using the Compare-and-Swap, the lock server returns the identifier of the client A to the client B, and the client B applies to the client A for the write lock using the Compare-and-Swap and according to the identifier of the client A. Before the client A releases the write lock, the client B is in a write lock waiting state.
In an implementation solution, when the client A is faulty, because the lock server does not know that the client B is in a write lock waiting state, the client B cannot obtain the write lock by means of application, and is constantly in the write lock waiting state. It can be known from the foregoing description that, the lock server can obtain a lock state of only one current client.